package com.fz.song.service;

import com.fz.song.mapper.HmUserMapper;
import com.fz.song.pojo.HmUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class HiServiceImpl implements HiService {

    @Autowired
    private HmUserMapper hmUserMapper;

    @Override
    public HmUser selectByPrimaryKey(int id) {
        return hmUserMapper.selectByPrimaryKey(id);
    }

    @Override
    public int insertSelective(HmUser hmUser) {
        return hmUserMapper.insertSelective(hmUser);
    }

    @Override
    @Transactional
    public String testTransactional() {

        HmUser hmUser1 = hmUserMapper.selectByPrimaryKey(1);
        HmUser hmUser2 = hmUserMapper.selectByPrimaryKey(2);

        hmUser1.setPassword("111111");
        hmUser2.setPassword("222222");
        int i1 = hmUserMapper.updateByPrimaryKeySelective(hmUser1);
//        int i = 1 / 0;
        int i2 = hmUserMapper.updateByPrimaryKeySelective(hmUser2);

        return "success";

    }
}

